package org.dreamfly.core.remote.generator;

/**
 * Created by IntelliJ IDEA.
 * User: Gin
 * Date: 2010-11-26
 * Time: 22:43:24
 * To change this template use File | Settings | File Templates.
 */

import org.dreamfly.core.remote.register.ServiceProxyGenerator;
import org.springframework.remoting.caucho.HessianProxyFactoryBean;

import java.util.Properties;


/**
 * @see 
 *
 * @author Tony
 */
public class HessianServiceProxyGenerator implements ServiceProxyGenerator {

    /** Hessian服务代理工厂 */
    private HessianProxyFactoryBean hessianProxyFactory = new HessianProxyFactoryBean();

    /*
     * @see com.alipay.xfiredemo.common.ServiceProxyGenerator#getService(java.lang.Class, java.lang.String,
     *      java.util.Properties)
     */
    public Object getService(Class serviceClass, String serviceUrl, Properties props) {

        // Todo initial hessianProxyFactory with props

        hessianProxyFactory.setServiceInterface(serviceClass);
        hessianProxyFactory.setServiceUrl(serviceUrl);

        // must invoke this method
        hessianProxyFactory.afterPropertiesSet();
        System.out.println(hessianProxyFactory.isSingleton());
        return hessianProxyFactory.getObject();
    }

}